import { request } from '@/service'

interface ResultType {
  result: {
    resultCode: string
    resultMessage: string
  }
  data: object
}

/** 适配接口返回结果 */
function adapter(obj: ResultType) {
  if (obj.result?.resultCode === '000000') {
    return obj.data
  }

  throw new Error('错误')
}

/** 实时数据监测 start */
//查询能源类型查询监测点位状态及数量
export const queryJcdwTjInfoList = (params?: any) =>
  request.get('/jcdw/queryJcdwTjInfoList', { params }).then((res: any) => adapter(res))

//查询监测点位图表数据
export const queryJcdwTbInfo = (params?: any) =>
  request.get('/jcdw/queryJcdwTbInfo', { params }).then((res: any) => adapter(res))

//查询企业监测点位列表
export const queryJcdwInfoList = (params?: any) =>
  request.get('/jcdw/queryJcdwInfoList', { params }).then((res: any) => adapter(res))

//查询企业监测点位列表
export const queryJcdwInfo = (params?: any) =>
  request.get('/jcdw/queryJcdwInfo', { params }).then((res: any) => adapter(res))

//查询时间间隔字典
export const querySjjgZdInfo = (params?: any) =>
  request.get('/zd/querySjjgZdInfo', { params }).then((res: any) => adapter(res))
/** 实时数据监测 end */

/** 电力一张图 start */
//查询电力一张图数据
export const queryDlYztInfo = (params?: any) =>
  request.get('/jcdw/queryDlYztInfo', { params }).then((res: any) => adapter(res))
/** 电力一张图 end */

/** 能源监测地图 start */
//根据企业id查询企业标牌
export const queryQyBpInfo = (params?: any) =>
  request.get('/jcdw/queryQyBpInfo', { params }).then((res: any) => adapter(res))
/** 能源监测地图 end */

/** 历史数据查询 start */
//根据监测点位查询年度历史用电数据
export const queryJcdwyearHistoryInfo = (params?: any) =>
  request.get('/jcdw/queryJcdwyearHistoryInfo', { params }).then((res: any) => adapter(res))
//根据监测点位查询单日历史用电数据
export const queryJcdwDayHistoryInfo = (params?: any) =>
  request.get('/jcdw/queryJcdwDayHistoryInfo', { params }).then((res: any) => adapter(res))
/** 历史数据查询 end */
